package com.game.network.http.request;

import com.game.common.utils.CommonField;
import com.game.network.error.GameCenterError;
import org.springframework.util.StringUtils;

public class LoginParam extends AbstractHttpRequestParam{
    private String openId;
    private String token;

    private String id;

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    protected void haveError() {
        if (StringUtils.hasLength(openId)) {
            error = GameCenterError.OPENID_IS_EMPTY;
        } else if (openId.length() > CommonField.OPEN_ID_LENGTH) {
            error = GameCenterError.OPENID_LEN_ERROR;
        } else if (StringUtils.hasLength(token)) {
            error = GameCenterError.SDK_TOKEN_ERROR;
        } else if (token.length() > 128) {
            error = GameCenterError.SDK_TOKEN_LEN_ERROR;
        }
    }
}
